#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <assert.h>
#include <string.h>
char* my_strncpy(char* destion, const char* source, size_t num)
{
	int len = num;
	assert(destion && source);
	int sz = strlen(destion);
	char* ret = destion;
	if (num > sz)
	{
		while (num--)
		{
			*destion = *source;
			destion++;
			source++;
		}
		int rest = len - sz;
		while (rest--)
		{
			*destion = '\0';
		}
	}
	else
	{
		while (num--)
		{
			*destion = *source;
			destion++;
			source++;
		}
		*destion = '\0';
	}
	return ret;
}
int main()
{
	char arr1[] = "abcdef";
	char arr2[20]="as";
	char* ret = my_strncpy(arr2, arr1, 5);
	printf("%s\n", ret);
	printf("%s\n", arr2);
	return 0;
}